//package com.example.app.Utils;
//
//import android.os.Build;
//
//import androidx.annotation.RequiresApi;
//
//import java.util.Base64;
//
//import javax.crypto.Cipher;
//import javax.crypto.spec.SecretKeySpec;
//
//public class Util {
//    private static final String key = "ABCDEFGHIJKLMNOP"; // 16位密钥
//    @RequiresApi(api = Build.VERSION_CODES.O)
//    public static String encrypt(String strToEncrypt) {
//        try {
//            SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
//            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
//            cipher.init(Cipher.ENCRYPT_MODE, secretKey);
//            byte[] encryptedBytes = cipher.doFinal(strToEncrypt.getBytes());
//            return Base64.getEncoder().encodeToString(encryptedBytes);
//        } catch (Exception e) {
//            System.err.println("Error while encrypting: " + e.toString());
//        }
//        return null;
//    }
//
//    @RequiresApi(api = Build.VERSION_CODES.O)
//    public static String decrypt(String strToDecrypt) {
//        try {
//            SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
//            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
//            cipher.init(Cipher.DECRYPT_MODE, secretKey);
//            byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(strToDecrypt));
//            return new String(decryptedBytes);
//        } catch (Exception e) {
//            System.err.println("Error while decrypting: " + e.toString());
//        }
//        return null;
//    }
//}
